package com.hosever.utils;

import java.util.Random;

import org.apache.commons.lang.StringUtils;

/**
 * 字符串
 * @author Sever
 *
 */
public class SeverStringUtils extends StringUtils{
	/**
	 * 随机字符串
	 * @param length
	 * @return
	 */
	public static String getRandomString(int length){
		String str="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
		Random  random = new Random();
		StringBuffer buf = new StringBuffer();
		for(int i = 0 ;i < length ; i ++){
			int num = random.nextInt(62);
			buf.append(str.charAt(num));
		}
	  
		return buf.toString();
	}
	
	/**
	 * 首字母转小写
	 * @param s
	 * @return
	 */
	public static String toLowerCaseFirstOne(String s){
        if(Character.isLowerCase(s.charAt(0)))
            return s;
        else
            return (new StringBuilder()).append(Character.toLowerCase(s.charAt(0))).append(s.substring(1)).toString();
    }
    /**
     * 首字母转大写
     * @param s
     * @return
     */
	public static String toUpperCaseFirstOne(String s){
        if(Character.isUpperCase(s.charAt(0)))
            return s;
        else
            return (new StringBuilder()).append(Character.toUpperCase(s.charAt(0))).append(s.substring(1)).toString();
    }
}
